import { FieldType } from 'choerodon-ui/pro/lib/data-set/enum';
import Record from 'choerodon-ui/pro/lib/data-set/Record';

interface changeProps {
  record: Record;
  name: string;
  value: string;
  oldValue: string;
}

function handleDataSetChange({ record, name, value, oldValue }: changeProps) {
  console.log('[dataset newValue]', value, '[oldValue]', oldValue, `[record.get('${name}')]`, record.get(name));
}

const inputDs = () => ({
  autoCreate: true,
  fields: [
    { name: 'color', type: FieldType.color, defaultValue: '#00ff00', required: true },
  ],
  events: {
    update: handleDataSetChange,
  },
});


export default inputDs;